<template>
	<!-- 店铺基本信息页面 -->
	<div>
		<MyNavbar title="店铺基本信息" />
		
		<div class="base-box">
			<u-form :model="form" labelPosition="top" labelWidth="100%">
				<u-form-item label="店铺封面">
					<MyImgUpload v-model="form.shopImg"/>
				</u-form-item>
				<u-form-item label="店铺名称">
					<u-input v-model="form.shopName" placeholder="店铺名称"/>
				</u-form-item>
				<u-form-item  label="营业时间">
					<u-input v-model="form.busHours" placeholder="营业时间"/>
				</u-form-item>
				
				<u-form-item>
					<u-button type="primary" text="保 存" @click="onClickSubmit"></u-button>
				</u-form-item>
			</u-form>
		</div>
	</div>
</template>

<script>
	import MyImgUpload from '@/components/form/MyImgUpload.vue';
	
	export default {
		components: {
			MyImgUpload
		},
		data() {
			return {
				// 表单
				form: {
					shopImg: null,
					busHours: null,
					shopName: null,
				},
			}
		},
		computed: {
			
		},
		//  触发下拉刷新
		onPullDownRefresh(){
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onLoad(){
			this.getShopInfo();
		},
		methods: {
			// 获取当前账号店铺信息
			getShopInfo(){
				this.$api.shop.get().then(res=>{
					let list = res.data;
					if (list && list.length > 0) {
						this.form = list[0];
					} else {
						this.$utils.showToast('当前账号无店铺');
					}
				});
			},
			// 点击保存
			onClickSubmit(){
				let form = this.form;
				this.$api.shop.save(form).then(res=>{
					this.$utils.showSuccess('保存成功');
				});
			},
		},
	}
	
</script>

<style>
</style>
